import pagination from '@/views/pagination'  //分页组件
import Popup from './edit'   //弹窗组件
import agentHttp from '@/utils/agentHttp.js'
import {debounce,timestampToTime} from '@/utils/index.js'
import Edit from  "./edit.vue";
import exportExcel from '@/utils/exportExcel' //导出
export default {
  name: 'priceAudit',
  mounted(){
   this.seachData()
  },
  components:{
    Edit,pagination
  },
  data() {
  	return {
      //搜索字段
  		searchForm:{
  			startDate:"",     //经销商
        endDate:"",      //申请时间
        orderNumber:"",        //订单号
        dealerName:"",   //经销商名称
        carSubBrandNameAndCarName:"",     //汽车子品牌加汽车车型
      },
      //表格字段
      tableData: [],
      dialogSendData:{
        isCode:false,        //弹窗是否显示        true是   false否  
        isAdd:false,         //弹窗内容是否可编辑
        isMsg:null,        //弹窗初始化时 是否发请求        、、默认发  
        id:null,
      },
      startDateOpt: {
        disabledDate(time) {
          return time.getTime() > Date.now() 
        }
      },
      endDateOpt:{
        disabledDate:(time)=>{
          return  time.getTime()< new Date(this.searchForm.startDate).getTime();
        }
      },

  	}
  },

  methods: {
    seachData(){     
        var params = this.searchForm||{};
        params.page=this.tableData.page||1;
        params.rows=this.tableData.rows||10;
        agentHttp.postJson(`adminApi/admin/car_order_record/list?page=${params.page}&rows=${params.rows}`,params ).then((data)=>{
          this.tableData = data
          // console.dir(data.data)
    })
      },
    debounceSeach(){      //input框内容发生改变时，调接口显示查询结果
      this.tableData.page=1;
      debounce(this.seachData(this.searchForm),1000)
    },
    exportExcels(searchForm,url,name){
      exportExcel(searchForm,url,name)
    },
    //显示子组件 
    toggleEdit(isAdd,msg,id){
      this.dialogSendData.isCode =  true;
      this.dialogSendData.isAdd =  isAdd;
      this.dialogSendData.isMsg = msg;
      this.dialogSendData.id = id ;
    },
    getDate(time){
      return timestampToTime(time)
    },
    //重置
    resetSearchForm(formName) {
      this.resetFormStatus=true;
      this.tableData.page=1;
      this.tableData.rows=10;
      this.$refs[formName].resetFields();
      this.$nextTick(_ =>{
        this.resetFormStatus=false;
        this.seachData();
      })
    },
   
  }
}